﻿using ConfExpert.Forms.Base;
using DevExpress.XtraEditors.Repository;
using DevTeam;
using System;
using System.Drawing;

namespace ConfExpert.Forms.Siparisler
{
    public partial class PLTemplates : XForm
    {
        public PLTemplates()
        {
            InitializeComponent();
        }

        private void PLTemplates_Load(object sender, EventArgs e)
        {
            gridView1.Init("GetPLTemplates2");
            gridView1.AddDetailGrid(gridView2, "PLTemplateId");

            RepositoryItemMemoExEdit ri = new RepositoryItemMemoExEdit();
            ri.ShowIcon = false;
            ri.PopupFormMinSize = new Size(500, 300);
            gridView1.Columns["GroupingQuery"].ColumnEdit = ri;

            gridView1.AddAutoIncrementalPK("PLTemplateId");
            gridView2.AddAutoIncrementalPK("PLTemplateColumnsId");

            gridView1.SetCaptions("PLTemplateId:#");
            gridView2.SetCaptions("PLTemplateColumnsId:#");

            gridView1.EnableNewRow();
            gridView2.EnableNewRow();

            gridView1.EnableRowDelete();
            gridView2.EnableRowDelete();

            gridView1.SetViewCaption("PL Tipleri");
            gridView2.SetViewCaption("Düzen");
            gridView1.AddSummary();
            gridView2.AddSummary();

            gridView1.BestFitColumns();
            gridView2.BestFitColumns();
            gridView1.FocusedRowChanged += gridView1_FocusedRowChanged;
            btnKaydet.ItemClick += btnKaydet_ItemClick;

            splitContainerControl1.AutoSize();
        }

        void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            gridView2.BestFitColumns();
        }

        void btnKaydet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            gridView1.UpdateAll();
        }
    }
}
